<?php
require_once('controller/auth.php');
//Start session
@session_start();

//Include database connection details
require_once('controller/inc/config.inc');

//Array to store validation errors
$errmsg_arr = array();

//Validation error flag
$errflag = false;

//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
	die('Failed to connect to server: ' . mysql_error());
}

//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
	die("Unable to select database");
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
<title>Project Tracking MIS</title>

<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="https://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
<![endif]-->
<!-- Le styles -->
<link rel="stylesheet" href="assets/css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="assets/css/bootstrap-responsive.css"
	type="text/css" />
<link rel="stylesheet" href="assets/css/font-awesome.css"
	type="text/css" />
	<link rel='stylesheet' href='assets/css/datepicker.css'>
<script type="text/javascript" src="assets/js/jquery.min.js"></script>
<script type="text/javascript" src='assets/js/bootstrap-datepicker.js'></script>
<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-popover.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-tooltip.js"></script>
<!-- Ali sajjad Modifications may 18th Begins-->
<script type="text/javascript" src="assets/js/highcharts.js"></script>

<script src="assets/js/exporting.js"></script>
<?php 
$sql = "SELECT proj_name, status FROM main ORDER BY prepared_date DESC LIMIT 10";
$res = mysql_query($sql) or die("Error : ".mysql_error());
$stat = array();
?>
<script type="text/javascript">


$(function () {
        $('.charts1').highcharts({
            chart: {
                type: 'column'
            },
            title: {
                text: 'Stacked column chart of Ted Projects'
            },
            xAxis: {
                //categories: ['P1', 'P2', 'P3','P4', 'P5', 'P6','P7', 'P8', 'P9','P10']
            	categories: [<?php while($row = mysql_fetch_array($res)){echo "'".$row[0]."',";$stat[]=$row[1];}?>]
            
                },
            yAxis: {
                min: 0,
                title: {
                    text: 'TED Projects Progress Status'
                },
                stackLabels: {
                    enabled: true,
                    style: {
                        fontWeight: 'bold',
                        color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
                    }
                }
            },
            legend: {
                align: 'right',
                x: -100,
                verticalAlign: 'top',
                y: 20,
                floating: true,
                backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
                borderColor: '#CCC',
                borderWidth: 1,
                shadow: false
            },
            tooltip: {
                formatter: function() {
                    return '<b>'+ this.x +'</b><br/>'+
                        this.series.name +': '+ this.y +'<br/>'+
                        'Total: '+ this.point.stackTotal;
                }
            },
            plotOptions: {
                column: {
                    stacking: 'normal',
                    dataLabels: {
                        enabled: true,
                        color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
                    }
                }
            },
            /*
            First Solution
            Use aRRay

            <?php 
            $stage1 = array();
            $stage2 = array();
            $stage3 = array();
            $stage4 = array();
            $stage5 = array();
            for($i=0;$i<count($stat);$i++){
            	switch($stat[$i]){
            		case 0:
            			$stage1[] = 10;
            			$stage2[] = 0;
            			$stage3[] = 0;
            			$stage4[] = 0;
            			$stage5[] = 0;
            			break;
            		case 1:
            			$stage1[] = 10;
            			$stage2[] = 30;
            			$stage3[] = 0;
            			$stage4[] = 0;
            			$stage5[] = 0;
            			break;
            		case 2:
            			$stage1[] = 10;
            			$stage2[] = 30;
            			$stage3[] = 40;
            			$stage4[] = 0;
            			$stage5[] = 0;
            			
            			break;
            		case 4:
            			$stage1[] = 10;
            			$stage2[] = 30;
            			$stage3[] = 30;
            			$stage4[] = 20;
            			
            			$stage5[] = 10;
            			
            			break;
            		
            	
            	}
            }
            
            
            ?>
            
            */
            series: [{
                name: 'Stage5',
                data: [<?php echo implode(",", $stage5)?>]
            }, {
                name: 'Stage4',
                data: [<?php echo implode(",", $stage4)?>]
            }, {
                name: 'Stage3',
                data: [<?php echo implode(",", $stage3)?>]
            },{
                name: 'Stage2',
                data: [<?php echo implode(",", $stage2)?>]
            },{
                name: 'Stage1',
                data: [<?php echo implode(",", $stage1)?>]
            }]
        });
    });
    

            
                        
</script>

<!--  
<script type="text/javascript">
$(function () {
        $('.charts2').highcharts({
            chart: {
                type: 'column'
            },
            title: {
                text: 'Total Teachers Grouped by Gender & Project Executer'
            },
            subtitle: {
                text: ''
            },
            xAxis: {
                categories: [
                    'Undefined',
                    'Male',
                    'Female'
                ]
            },
            yAxis: {
                min: 0,
                title: {
                    text: 'Teachers Count'
                }
            },
            tooltip: {
                headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
                pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                    '<td style="padding:0"><b>{point.y:.0f} teachers</b></td></tr>',
                footerFormat: '</table>',
                shared: true,
                useHTML: true
            },
            plotOptions: {
                column: {
                    pointPadding: 0.2,
                    borderWidth: 0
                }
            },
            series: [{
                name: 'ADA',
                data: [134, 39521, 21581]
    
            }, {
                name: 'JAC',
                data: [0, 25273, 6417]
    
            }, {
                name: 'SC',
                data: [10, 9183, 2589]
    
            }]
        });
    });
    

		</script>
-->

<!-- Ali sajjad Modifications may 18th Begins -->
 


<script>
$(function ()
{ 
$("input").popover({trigger: 'focus', 'placement':'right'});

$("textarea").popover({trigger: 'focus'});


$('#tab').tooltip({'placement':'right', 'trigger' : 'hover'});

$('a').tooltip({'placement':'bottom', 'trigger' : 'hover'});	
});
</script>

<style>
body {
	padding-top: 60px;
	padding-bottom: 40px;
}

.sidebar-nav {
	padding: 9px 0;
}

.dropdown-menu .sub-menu {
	left: 100%;
	position: absolute;
	top: 0;
	visibility: hidden;
	margin-top: -1px;
}

.dropdown-menu li:hover .sub-menu {
	visibility: visible;
	display: block;
}

.navbar .sub-menu:before {
	border-bottom: 7px solid transparent;
	border-left: none;
	border-right: 7px solid rgba(0, 0, 0, 0.2);
	border-top: 7px solid transparent;
	left: -7px;
	top: 10px;
}

.navbar .sub-menu:after {
	border-top: 6px solid transparent;
	border-left: none;
	border-right: 6px solid #fff;
	border-bottom: 6px solid transparent;
	left: 10px;
	top: 11px;
	left: -6px;
}
</style>
<!-- Le fav and touch icons -->

</head>

<body>
<div class="container-fluid"><!--TOp Nav-->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid"><a data-target=".nav-collapse"
	data-toggle="collapse" class="btn btn-navbar"> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span> </a> <a
	href="#" class="brand">TMIS | Project Tracking</a>
<div class="nav-collapse">
<ul class="nav">
	<li><a href="dashboard.php">Home Page</a></li>
	<li><a href="create_project.php">Create Project</a></li>
	<li ><a href="update_project.php">Update Project</a></li>
	<li class='active'><a href="reports.php">Reports</a></li>

</ul>
<form action="" class="navbar-search pull-left">
<input type="text" placeholder="Search" class="search-query span2">

</form>
<ul class="nav pull-right">


	<div class="pull-right">
	<ul class="nav pull-right">
		<li class="dropdown"><a href="#" class="dropdown-toggle"
			data-toggle="dropdown">Welcome, <?php echo $_SESSION['SESS_FIRST_NAME'] . " " . $_SESSION['SESS_LAST_NAME'];?>
		<b class="caret"></b></a>
		<ul class="dropdown-menu">
			<li><a href="/user/preferences"><i class="icon-cog"></i> Preferences</a></li>
			<li><a href="/help/support"><i class="icon-envelope"></i> Contact
			Support</a></li>
			<li class="divider"></li>
			<li><a href="controller/logout.php"><i class="icon-off"></i> Logout</a></li>
		</ul>
		</li>
	</ul>
	</div>


</ul>
</div>
<!-- /.nav-collapse --></div>
</div>
</div>





 <!--/Top Nav-->


 
 <div id="lC1" class="tab-pane charts1">
                  
 </div>
<div class="row-fluid">

<hr />
<footer class="footer"> &copy;2013 TMIS, TED, MoE </footer></div>

</body>

</html>
 